package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ExpEquUsed;
import com.ruoyi.system.service.IExpEquUsedService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 器材使用申请Controller
 * 
 * @author kk
 * @date 2023-06-20
 */
@RestController
@RequestMapping("/system/exp_equ_used")
public class ExpEquUsedController extends BaseController
{
    @Autowired
    private IExpEquUsedService expEquUsedService;

    /**
     * 查询器材使用申请列表
     */
    @PreAuthorize("@ss.hasPermi('system:exp_equ_used:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExpEquUsed expEquUsed)
    {
        startPage();
        List<ExpEquUsed> list = expEquUsedService.selectExpEquUsedList(expEquUsed);
        return getDataTable(list);
    }

    /**
     * 导出器材使用申请列表
     */
    @PreAuthorize("@ss.hasPermi('system:exp_equ_used:export')")
    @Log(title = "器材使用申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExpEquUsed expEquUsed)
    {
        List<ExpEquUsed> list = expEquUsedService.selectExpEquUsedList(expEquUsed);
        ExcelUtil<ExpEquUsed> util = new ExcelUtil<ExpEquUsed>(ExpEquUsed.class);
        util.exportExcel(response, list, "器材使用申请数据");
    }

    /**
     * 获取器材使用申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:exp_equ_used:query')")
    @GetMapping(value = "/{expID}")
    public AjaxResult getInfo(@PathVariable("expID") String expID)
    {
        return success(expEquUsedService.selectExpEquUsedByExpID(expID));
    }

    /**
     * 新增器材使用申请
     */
    @PreAuthorize("@ss.hasPermi('system:exp_equ_used:add')")
    @Log(title = "器材使用申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExpEquUsed expEquUsed)
    {
        return toAjax(expEquUsedService.insertExpEquUsed(expEquUsed));
    }

    /**
     * 修改器材使用申请
     */
    @PreAuthorize("@ss.hasPermi('system:exp_equ_used:edit')")
    @Log(title = "器材使用申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExpEquUsed expEquUsed)
    {
        return toAjax(expEquUsedService.updateExpEquUsed(expEquUsed));
    }

    /**
     * 删除器材使用申请
     */
    @PreAuthorize("@ss.hasPermi('system:exp_equ_used:remove')")
    @Log(title = "器材使用申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{expIDs}")
    public AjaxResult remove(@PathVariable String[] expIDs)
    {
        return toAjax(expEquUsedService.deleteExpEquUsedByExpIDs(expIDs));
    }
}
